package WaiBao;

import java.util.Arrays;

public class DengXingHuan {
    public static void main(String[] args) {
        String[] name = {"郝冰(班长)", "李大红(副班长)", "小李(学习委员)", "刘德华(纪律委员)", "张紫薇(生活委员)", "李冰", "何亚东", "欧阳修", "典韦", "苏有朋", "张大大", "杨浩天",
                "程咬金", "李元芳", "包青天", "张华宇", "李海燕", "司空郑", "关羽", "马超", "马腾", "马子文", "东方镜", "东方耀", "李高层", "王田丽", "无锡", "李存勖",
                "鹿晗", "邓鑫欢(学生)"};//考生本人:邓鑫欢(学生)
        int[] age = {21, 22, 21, 18, 21, 22, 21, 21, 19, 20, 19, 18, 21, 21, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 21, 18, 21, 22, 21, 20};//考生年龄20

        double[] talk1 = {84, 82, 84, 64, 88, 89, 71, 59, 60, 74, 94, 87, 84, 77, 65, 68, 65, 74, 86, 88, 95, 91, 95, 85, 75, 74, 74, 72, 84, 94};
        double[] talk2 = {72, 77, 77, 87, 75, 67, 71, 79, 83, 91, 74, 74, 76, 77, 45, 75, 84, 79, 86, 68, 84, 71, 84, 81, 75, 84, 84, 88, 87, 94};
        double[] talk3 = {77, 89, 89, 85, 80, 79, 69, 84, 84, 74, 83, 87, 85, 84, 65, 78, 89, 79, 96, 63, 92, 81, 95, 85, 76, 81, 77, 71, 74, 95};



        double wuwei1;//代表每个学生的总分
        double wuwei2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            wuwei1 = talk1[i] + talk2[i] +talk3[i];
//            wuwei2 = (wuwei1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" +wuwei1);
//            System.out.println(name[i] + "的平均分为:" +wuwei2);
//        }

        double maoxian1 = 0,maoxian2 = 0;
        double[] Array = new double[30];
//        for (int i = 0; i < 30; i++) {
//            maoxian1 = talk1[i] + talk2[i] + talk3[i];
//            maoxian2 = (maoxian1 * 1.0) / 3;
//            Array[i] = maoxian2;
//        }
//
//        for (int i = 0; i < Array.length - 1; i++) {
//            for (int j = 0; j < Array.length - i - 1; j++) {
//                if (Array[j] < Array[j + 1]) {
//                    double temp = Array[j];
//                    Array[j] = Array[j + 1];
//                    Array[j + 1] = temp;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(Array[i]);
//        }


        double green1 = 0,green2 = 0,green3 = 0;//计算每门课的平均分
        double fun1 = 0, fun2 = 0,fun3 = 0;//计算每门课标准差
        double blue1 = 0, blue2 = 0, blue3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < talk1.length; i++) {
            sum2+=talk1[i];
        }
        green1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+green1);
        double Sum = 0;
        for (int i = 0; i <talk2.length; i++) {
            Sum+=talk2[i];
        }
        green2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+green2);
        double sum = 0;
        for (int i = 0; i <talk3.length; i++) {
            sum+=talk3[i];
        }
        green3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+green3);



        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i <talk1.length; i++) {
            c1+= (talk1[i] - green1)*(talk1[i] - green1);
        }
        fun1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+fun1);

        for (int i = 0; i < talk2.length; i++) {
            c2+= (talk2[i] - green2)*(talk2[i] - green2);
        }
        fun2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+fun2);

        for (int i = 0; i < talk3.length; i++) {
            c3+= (talk3[i] -green3)*(talk3[i] -green3);
        }
        fun3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+fun3);
//////////
        Arrays.sort(talk1);
        Arrays.sort(talk2);
        Arrays.sort(talk3);
        blue1 =( talk1[15]+talk1[14])*1.0/2;
        blue2 =( talk2[15]+talk2[14])*1.0/2;
        blue3 =( talk3[15]+talk3[14])*1.0/2;
        System.out.println("分析化学的中位数为:"+blue1);
        System.out.println("线性代数的中位数为:"+blue2);
        System.out.println("有机化学学的中位数为:"+blue3);





    }
}
